//  sessionStorage.getItem('goodsId')
//  console.log(sessionStorage.getItem('goodsId'))
 
 $.get("goodsAndShoppingCart/getGoodsInfo.php",
 {
 "goodsId":sessionStorage.getItem('goodsId')
 },
 function(data){
    // for(let i=0;i<data.len)
    let json = JSON.parse(data)
      console.log(json)
      $(".details-kuang-tu>img").attr("src", `img/liebiao/${json["goodsImg"]}`);

      $(".datu").css({
        "background": `url(img/liebiao/${json["goodsImg"]}) no-repeat`,
        "background-size": "4160px 4160px",
        "background-position": "100px"
      })


      $(".details-mingcheng").html(`${json["goodsName"]}`)
      $(".z1").html(`${json["goodsName"]}`)


      $(".details-jiage").html(`￥${json["goodsPrice"]}`)

      $(".z2").html(`￥${json["goodsPrice"]}`)
  
//判断是否登录
      // sessionStorage.getItem('vipName')
      // console.log(sessionStorage.getItem('vipName'))
 

      })



      function tianjia(){

 
        $.post("goodsAndShoppingCart/addShoppingCart.php",
        
        {
         "vipName":sessionStorage.getItem('vipName'),
          "goodsId":sessionStorage.getItem('goodsId'),
          "goodsCount":1
        },
        function(data1){
          console.log(data1)
          if(data1==1){
            alert("添加成功 ")
            // console.log("succer")
          }else{
            alert("添加失败")
            // console.log("shibai")
          }
      })

    }



  //检验添加
    
    $(".gouwuche-0").click(function(){
      if(sessionStorage.getItem('vipName')==null){
        alert("请先登录")
        window.location.href="denglu.html"
      }else{
        tianjia("添加失败，请重新添加")
      }
    })

    // let a = json.length
    // for(let i= 0;i<a;i++){
    //   $(".ba-gongge").append('<div><div class="ba-gonggetu"><img src="img/1/da1.png" alt=""></div><div class="ba-gonggeming">DJl Mavic 3</div><div class="ba-gonggejiage"> ￥12888</div></div>')
  
    //   $(".ba-gonggetu>img").eq(i).attr("src", `img/liebiao/${json[i]["goodsImg"]}`);
    //   $(".ba-gonggeming").eq(i).html(`${json[i]["goodsName"]}`)
    //   $(".ba-gonggejiage").eq(i).html(`￥${json[i]["goodsPrice"]}`)
  
    //   sessionStorage.setItem('goodsId',`${json[i]["goodsId"]}`)
    //   // sessionStorage.setItem(json)
    //   // 跳转
    //   $(".ba-gonggetu>img").eq(i).click(function(){
    //     window.location.href="xianqing.html"
        
    //   })
  
    // }
  $(".mai-0").click(function(){
    window.location.href="gouwuche.html"
  })


 